package college;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * Class handles the Date and time variables within the project.
 * @author Group11
 *@see Calendar
 */

public class Date {
int day;
int month;
int year;
Calendar calendar;

/**
 * String - type constructor. <p>
 * Divides the values within the '/' and sets them into corresponding variables.
 * @param s - String to be turned into date.
 */
public Date(String s){
	try {
	String[] arr = s.split("/");
	this.day = Integer.parseInt(arr[0]);
	this.month = Integer.parseInt(arr[1]);
	this.year = Integer.parseInt(arr[2]);
	calendar = new GregorianCalendar();
calendar.set(year, month, day);
	}
	catch (Exception ex){
		System.out.println(ex.getMessage());
	}	

	
}

/**
 * @see getCalendar
 * @return
 */
public Calendar getCalendar()
{
	return calendar;
}

public Date(int day, int month, int year){
	this.day = day;
	this.month = month;
	this.year = year;
}
	
public String toString(){
	
	day=calendar.get(Calendar.DAY_OF_MONTH);
	month=calendar.get(calendar.MONTH);
	year=calendar.get(calendar.YEAR);
	return (this.day+"/"+this.month+"/"+this.year);
}


public void  addDays( int days)
{
	calendar.add(Calendar.DATE, days);
	
}
public int  subdate( Date a)
{

 
	long diff=a.getCalendar().getTimeInMillis()-calendar.getTimeInMillis();
	float day_count=(float)diff / (24 * 60 * 60 * 1000);
    return (int) day_count;
	
}




}
